<template>
  <div style="background-image: url('../../../static/img/sm3.jpeg');background-attachment:fixed;">
    <el-container>
      <el-main>
        <div class="hm">
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>用户信息管理</el-breadcrumb-item>
            <el-breadcrumb-item>地址信息管理</el-breadcrumb-item>
          </el-breadcrumb>

        </div>
        <addressList ref="addressList" :tableData="tableData"></addressList>
        <!--分页-->
        <el-pagination @current-change="paginationCurrentChange" :current-page.sync="currentPage" :page-size="pageSize"
                       layout="total, prev, pager, next, jumper" :total="dataLength" align="center">
        </el-pagination>

      </el-main>
    </el-container>
  </div>
</template>

<script>
import axios from 'axios'
import addressList from "../../components/list/addressList"

export default {

  name :"addressInfo",
  data() {

    return {
      dialoguploadVisible:false,
      input: '',
      dataLength: 0,
      currentPage:1,
      pageSize:5,
      tableData:[],
      userId:''
    }
  },
  methods: {
    //换页
    paginationCurrentChange(val){
      this.currentPage=val
      this.$refs.addressList.currentPage=this.currentPage
      this.tableData=this.selectAll(this)
    },
    selectAll(that){
      let token = sessionStorage.getItem('token')
      let url = this.$URL.userinfo+"?token="+token.replace("\"","")
      let url2 = url.substring(0,url.length -1)
      console.log("get"+url2)
      this.$axios.get(url2).then(res=>
      {
        this.userId=res.data.id
        console.log(this.userId)
        that.$axios.get(that.$URL.findaddressBycusId+'?id='+this.userId).then(
            res=>{
              console.log(res.data)
              that.tableData=res.data.list
              console.log(res.status)
              if(res.status==200){
                that.tableData=res.data
                console.log("father")
                console.log(that.tableData)
              }
            }
        ).catch(err=>{})
      }).catch(err=>{})
    },

    handleClick(){
      this.$Bus.$emit('addaddress',{
        dialogVisible:true
      })
    }
  },
  components: {
    addressList
  },
  mounted () {
    // console.log("zhehsi222"+this.userId)
    this.tableData=this.selectAll(this)
  },
}
</script>

<style lang="less" scoped>
.el-container {
  border: 1px solid #ddd;
  border-radius: 10px;
  margin: 10px;
  padding: 10px;
  min-height: 500px;
  .el-aside {
    color: #fff;

    .el-input {
      margin-bottom: 15px;
      width: 250px;
    }

    .el-menu {
      border-top: 1px solid #ddd;
      border-radius: 5px;
      width: 250px;
      min-height: 500px;
    }
  }

  .el-main {
    .hm {
      margin-bottom: 10px;
      margin-left: 30px;
    }
  }
}
</style>